babl: further nan prevention in babl-trc
authorØyvind Kolås <pippin@gimp.org>
Sun, 10 Sep 2017 22:41:47 +0000 (00:41 +0200)
committerØyvind Kolås <pippin@gimp.org>
Sun, 10 Sep 2017 23:45:15 +0000 (01:45 +0200)
babl/babl-trc.c

index 6f97d83473b8de4ad6b7be5edd5b6a3916b12737..7fa79f1a7493e09870231071a59778ecd7004e40 100644 (file)
@@ -417,9 +417,13 @@ static inline float _babl_trc_formula_srgb_from_linear (const Babl *trc_, float
   {
     float v = babl_powf (x, 1.0/g);
     v = (v-b)/a;
-    return v;
+    if (v < 0.0 || v >= 0.0)
+      return v;
+    return 0.0;
   }
-  return x / c;
+  if (c > 0.0)
+    return x / c;
+  return 0.0;
 }
 
 static inline float _babl_trc_formula_srgb_to_linear (const Babl *trc_, float value)